package com.game.majiang.vo;

import java.sql.SQLException;
import java.util.HashMap;

import javax.sql.rowset.CachedRowSet;

import com.game.majiang.config.LogManager;
import com.game.server.db.Parameter;
import com.game.server.db.SqlHelper;

import lombok.Data;

/**
 * 房间信息
 * 
 * @author 
 */
@Data
public class RoomConfigVo {
	
	 /** room id */
    private Short id;
    
    /** 名字 */
    private String name;
    
    /**
     *人数限制
     */
    private int playerlimit;
    
    /**
     * 种类
     */
    private byte roomtype;//1 老虎机 2拉斯维加斯 3转盘   
    

    public static HashMap<Integer, RoomConfigVo> getRoomConfigVo()
    {
    	String cmdText = "select g.roomid, g.playerlimit, g.name, g.roomtype from roomconfig g";
		LogManager.getInstance().Log("房间初始化好好 ");
    	CachedRowSet rs = SqlHelper.getResultSet(cmdText, new Parameter[0]);
    	HashMap<Integer, RoomConfigVo> maps = new HashMap<Integer, RoomConfigVo>();
    	try {
    		  while (rs.next())
	          {
    		    RoomConfigVo vo = new RoomConfigVo();
	             vo.id = (short)rs.getInt(1);
	             vo.playerlimit = rs.getInt(2);
	             vo.name = rs.getString(3);
	             vo.roomtype = (byte)rs.getInt(4);
	             maps.put((int)vo.id, vo);
	         }
		 } catch (SQLException e) {
			// TODO Auto-generated catch block
			 e.printStackTrace();
		 }
 
    	return maps;
    }
}
